@import '@devui/theme/styles-var/devui-var.scss';

$devui-timeline-item-dot-size: 18px;

.#{$devui-prefix}-timeline {
  &-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;

    .#{$devui-prefix}-timeline-item {
      display: flex;
      flex-direction: row;
      width: 100%;

      &-axis {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 12px;
      }

      &-line {
        position: relative;
        height: calc(100% - #{$devui-timeline-item-dot-size});
        min-height: 20px;
        border-left-width: 2px;
        border-left-color: $devui-dividing-line;

        &-extra {
          position: absolute;
          top: 50%;
          transform: translate(-50%, -50%);
        }

        &:first-child {
          display: none;
        }
      }

      &-data-left {
        text-align: end;
      }

      &-data-left,
      &-data-right {
        margin-bottom: 24px;
        margin-top: -2px;
        flex: 1;
      }

      &-line-style {
        &-dashed {
          border-left-style: dashed;
        }

        &-solid {
          border-left-style: solid;
        }

        &-dotted {
          border-left-style: dotted;
        }

        &-none {
          border-left-style: none;
        }
      }

      .#{$devui-prefix}-timeline-middle-zone {
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }

  &-horizontal {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: relative;

    &-center {
      .#{$devui-prefix}-timeline-item {
        &-data-top,
        &-data-bottom {
          text-align: center;
          padding: 0 6px;

          > div {
            transform: translateX(-50%);
          }
        }
      }
    }

    .#{$devui-prefix}-timeline-item {
      display: flex;
      flex-direction: column;
      height: 100%;

      &-axis {
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 12px 0;
      }

      &-line {
        position: relative;
        min-width: 60px;
        width: calc(100% - #{$devui-timeline-item-dot-size});
        border-bottom-width: 2px;
        border-bottom-color: $devui-dividing-line;

        &-extra {
          position: absolute;
          left: 50%;
          transform: translate(-50%, -50%);
        }
      }

      &:first-child {
        .#{$devui-prefix}-timeline-item-line {
          &:first-child {
            opacity: 0;
          }
        }
      }

      &-data-top,
      &-data-bottom {
        padding-right: 12px;
        flex: 1;
      }

      &-line-style {
        &-dashed {
          border-bottom-style: dashed;
        }

        &-solid {
          border-bottom-style: solid;
        }

        &-dotted {
          border-bottom-style: dotted;
        }

        &-none {
          border-bottom-style: none;
        }
      }

      .#{$devui-prefix}-timeline-middle-zone {
        position: absolute;
        left: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }
}

.#{$devui-prefix}-timeline-item {
  &-dot {
    &,
    & > svg {
      width: $devui-timeline-item-dot-size;
      height: $devui-timeline-item-dot-size;
      flex-shrink: 0;
    }

    & > i {
      font-size: $devui-timeline-item-dot-size;
      vertical-align: 0;
    }
  }

  //&:last-child {
  //  .#{$devui-prefix}-timeline-item-line {
  //    &:last-child {
  //      display: none;
  //    }
  //  }
  //}
  &-type {
    &-primary {
      border: 2px solid $devui-placeholder;
      border-radius: 50%;
    }

    &-success {
      i {
        color: $devui-success;
      }
    }

    &-error {
      i {
        color: $devui-danger;
      }
    }

    &-warning {
      i {
        color: $devui-warning;
      }
    }

    &-running {
      line-height: 16px;
      text-align: center;
      animation: devui-timeline-running 1.5s linear infinite;
      border: 2px solid $devui-success;
      border-radius: 50%;
    }
  }
}

@keyframes devui-timeline-running {
  0% {
    transform: rotate(0deg);
    color: $devui-success;
    border-color: $devui-success;
  }

  50% {
    transform: rotate(180deg);
    color: $devui-success;
    border-color: $devui-success;
  }

  100% {
    transform: rotate(360deg);
    color: $devui-success;
    border-color: $devui-success;
  }
}
